ODS 1
1.1.1
library(readxl)
url <- "https://github.com/ChiaraZamoraM/ODS/raw/main/1.1.1.xlsx"
destfile <- "X1_1_1.xlsx"
curl::curl_download(url, destfile)
X1_1_1 <- read_excel(destfile, skip = 28)
New names:
* `` -> ...1
* `` -> ...2
* `` -> ...3
* `` -> ...4
* `` -> ...5
* ...
colnames(X1_1_1) = paste0("ODS1_1_1_",colnames(X1_1_1))
X1_1_1 = X1_1_1[,c(1,10:26)]
names(X1_1_1)
[1] "ODS1_1_1_...1" "ODS1_1_1_...10" "ODS1_1_1_2013" "ODS1_1_1_...12" "ODS1_1_1_2014"
[6] "ODS1_1_1_...14" "ODS1_1_1_2015" "ODS1_1_1_...16" "ODS1_1_1_2016" "ODS1_1_1_...18"
[11] "ODS1_1_1_2017" "ODS1_1_1_...20" "ODS1_1_1_2018" "ODS1_1_1_...22" "ODS1_1_1_2019"
[16] "ODS1_1_1_...24" "ODS1_1_1_2020" "ODS1_1_1_...26"
X1_1_1[,c(2:18)]=lapply(X1_1_1[,c(2:18)], as.numeric)
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_1_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
X1_1_1$ODS1_1_1_2013= (X1_1_1$ODS1_1_1_2013+ X1_1_1$ODS1_1_1_...12)/2
X1_1_1$ODS1_1_1_2014= (X1_1_1$ODS1_1_1_2014+ X1_1_1$ODS1_1_1_...14)/2
X1_1_1$ODS1_1_1_2015= (X1_1_1$ODS1_1_1_2015+ X1_1_1$ODS1_1_1_...16)/2
X1_1_1$ODS1_1_1_2016= (X1_1_1$ODS1_1_1_2016+ X1_1_1$ODS1_1_1_...18)/2
X1_1_1$ODS1_1_1_2017= (X1_1_1$ODS1_1_1_2017+ X1_1_1$ODS1_1_1_...20)/2
X1_1_1$ODS1_1_1_2018= (X1_1_1$ODS1_1_1_2018+ X1_1_1$ODS1_1_1_...22)/2
X1_1_1$ODS1_1_1_2019= (X1_1_1$ODS1_1_1_2019+ X1_1_1$ODS1_1_1_...24)/2
X1_1_1$ODS1_1_1_2020= (X1_1_1$ODS1_1_1_2020+ X1_1_1$ODS1_1_1_...26)/2
names(X1_1_1)[1]= "DEPARTAMENTO"
X1_1_1 <- data.frame(X1_1_1[,seq(1,18,2)])
X1_1_1$DEPARTAMENTO= gsub("Lima Metropolitana","LIMA",X1_1_1$DEPARTAMENTO)
X1_1_1$DEPARTAMENTO= gsub("Lima","LIMA PROVINCIAS",X1_1_1$DEPARTAMENTO)
1.2.1
url <- "https://github.com/ChiaraZamoraM/ODS/raw/main/1.2.1.xlsx"
destfile <- "X1_2_1.xlsx"
curl::curl_download(url, destfile)
X1_2_1 <- read_excel(destfile, skip = 28)
New names:
* `` -> ...1
* `` -> ...2
* `` -> ...3
* `` -> ...4
* `` -> ...6
* ...
colnames(X1_2_1) = paste0("ODS1_2_1_",colnames(X1_2_1))
X1_2_1 = X1_2_1[,c(1,16:32)]
names(X1_2_1)
[1] "ODS1_2_1_...1" "ODS1_2_1_...16" "ODS1_2_1_2013" "ODS1_2_1_...18" "ODS1_2_1_2014"
[6] "ODS1_2_1_...20" "ODS1_2_1_2015" "ODS1_2_1_...22" "ODS1_2_1_2016" "ODS1_2_1_...24"
[11] "ODS1_2_1_2017" "ODS1_2_1_...26" "ODS1_2_1_2018" "ODS1_2_1_...28" "ODS1_2_1_2019"
[16] "ODS1_2_1_...30" "ODS1_2_1_2020" "ODS1_2_1_...32"
X1_2_1[,c(2:18)]=lapply(X1_2_1[,c(2:18)], as.numeric)
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
Warning in lapply(X1_2_1[, c(2:18)], as.numeric) :
NAs introduced by coercion
X1_2_1$ODS1_2_1_2013= (X1_2_1$ODS1_2_1_2013+ X1_2_1$ODS1_2_1_...18)/2
X1_2_1$ODS1_2_1_2014= (X1_2_1$ODS1_2_1_2014+ X1_2_1$ODS1_2_1_...20)/2
X1_2_1$ODS1_2_1_2015= (X1_2_1$ODS1_2_1_2015+ X1_2_1$ODS1_2_1_...22)/2
X1_2_1$ODS1_2_1_2016= (X1_2_1$ODS1_2_1_2016+ X1_2_1$ODS1_2_1_...24)/2
X1_2_1$ODS1_2_1_2017= (X1_2_1$ODS1_2_1_2017+ X1_2_1$ODS1_2_1_...26)/2
X1_2_1$ODS1_2_1_2018= (X1_2_1$ODS1_2_1_2018+ X1_2_1$ODS1_2_1_...28)/2
X1_2_1$ODS1_2_1_2019= (X1_2_1$ODS1_2_1_2019+ X1_2_1$ODS1_2_1_...30)/2
X1_2_1$ODS1_2_1_2020= (X1_2_1$ODS1_2_1_2020+ X1_2_1$ODS1_2_1_...32)/2
names(X1_2_1)[1]= "DEPARTAMENTO"
X1_2_1 <- data.frame(X1_2_1[,seq(1,18,2)])
X1_2_1$DEPARTAMENTO= gsub("Lima Metropolitana","LIMA",X1_2_1$DEPARTAMENTO)
X1_2_1$DEPARTAMENTO= gsub("Lima","LIMA PROVINCIAS",X1_2_1$DEPARTAMENTO)
1.3.1
url <- "https://github.com/ChiaraZamoraM/ODS/raw/main/1.3.1.xlsx"
destfile <- "X1_3_1.xlsx"
curl::curl_download(url, destfile)
X1_3_1 <- read_excel(destfile, skip = 7)
New names:
* `` -> ...1
colnames(X1_3_1) = paste0("ODS1_3_1_",colnames(X1_3_1))
X1_3_1[,c(2:14)]=lapply(X1_3_1[,c(2:14)], as.numeric)
names(X1_3_1)[1]= "DEPARTAMENTO"
X1_3_1$DEPARTAMENTO= gsub("Prov. Const. del Callao","Callao",X1_3_1$DEPARTAMENTO)
X1_3_1$DEPARTAMENTO= gsub("Provincia de Lima","LIMA",X1_3_1$DEPARTAMENTO)
X1_3_1$DEPARTAMENTO= gsub("Región Lima","LIMA PROVINCIAS",X1_3_1$DEPARTAMENTO)
1.4.1
ODS_1 = Reduce(function(x, y) merge(x, y, by= "DEPARTAMENTO"), list(X1_1_1, X1_2_1, X1_3_1, X1_4_1))
X1_4_1[,c(2:8)]=lapply(X1_4_1[,c(2:8)], as.numeric)
names(X1_4_1)[1]= "DEPARTAMENTO"
X1_4_1$DEPARTAMENTO= gsub("Prov. Const. del Callao","Callao",X1_4_1$DEPARTAMENTO)
X1_4_1$DEPARTAMENTO= gsub("Provincia de Lima","LIMA",X1_4_1$DEPARTAMENTO)
X1_4_1$DEPARTAMENTO= gsub("Región Lima","LIMA PROVINCIAS",X1_4_1$DEPARTAMENTO)
Merge
ODS_1 = Reduce(function(x, y) merge(x, y, by= "DEPARTAMENTO"), list(X1_1_1, X1_2_1, X1_3_1, X1_4_1))
ODS 2
url <- "https://www.inei.gob.pe/media/MenuRecursivo/publicaciones_digitales/Est/Lib1795/cuadros/Cap010.xls"
destfile <- "Cap010.xls"
curl::curl_download(url, destfile)
Cap010 <- read_excel(destfile,sheet = "10.18",skip = 6)
New names:
* `` -> ...2
* `` -> ...3
* `` -> ...4
* `` -> ...5
* `` -> ...6
* ...
names(Cap010)[c(1,4)]= c("DEPARTAMENTO","2020")
Cap010 =Cap010[,c(1,4)]
Cap010$DEPARTAMENTO =gsub(' [0-9].', '', Cap010$DEPARTAMENTO)
url <- "https://www.inei.gob.pe/media/MenuRecursivo/publicaciones_digitales/Est/Lib1795/cuadros/Cap010.xls"
destfile <- "Cap010.xls"
curl::curl_download(url, destfile)
Cap010_2 <- read_excel(destfile,sheet = "10.18",skip = 6)
New names:
* `` -> ...2
* `` -> ...3
* `` -> ...4
* `` -> ...5
* `` -> ...6
* ...
names(Cap010_2)[c(1,7)]= c("DEPARTAMENTO","2020")
Cap010_2 =Cap010_2[,c(1,7)]
Cap010_2$DEPARTAMENTO =gsub(' [0-9].', '', Cap010_2$DEPARTAMENTO)
2.1.1
url <- "https://github.com/ChiaraZamoraM/ODS/raw/main/2.2.1.xlsx"
destfile <- "X2_2_1.xlsx"
curl::curl_download(url, destfile)
X2_2_1 <- read_excel(destfile, skip = 7)
New names:
* `` -> ...1
names(X2_2_1)[1]= "DEPARTAMENTO"
Cap010$DEPARTAMENTO= gsub("Prov. Const. del Callao","Callao",Cap010$DEPARTAMENTO)
Cap010$DEPARTAMENTO= gsub("Lima Metropolitana","LIMA",Cap010$DEPARTAMENTO)
Cap010$DEPARTAMENTO= gsub("Departamento de Lima","LIMA PROVINCIAS",Cap010$DEPARTAMENTO)
X2_2_1$DEPARTAMENTO= gsub("Prov. Const. del Callao","Callao",X2_2_1$DEPARTAMENTO)
X2_2_1$DEPARTAMENTO= gsub("Provincia de Lima","LIMA",X2_2_1$DEPARTAMENTO)
X2_2_1$DEPARTAMENTO= gsub("Región Lima","LIMA PROVINCIAS",X2_2_1$DEPARTAMENTO)
X2_2_1 = merge(X2_2_1, Cap010, by = "DEPARTAMENTO")
names(X2_2_1)[c(2:15)] = paste0("ODS2_2_1_",names(X2_2_1)[c(2:15)])
2.2.1
url <- "https://github.com/ChiaraZamoraM/ODS/raw/main/2.2.2.xlsx"
destfile <- "X2_2_2.xlsx"
curl::curl_download(url, destfile)
X2_2_2 <- read_excel(destfile, skip = 7)
New names:
* `` -> ...1
names(X2_2_2)[1]= "DEPARTAMENTO"
Cap010_2$DEPARTAMENTO= gsub("Prov. Const. del Callao","Callao",Cap010_2$DEPARTAMENTO)
Cap010_2$DEPARTAMENTO= gsub("Lima Metropolitana","LIMA",Cap010_2$DEPARTAMENTO)
Cap010_2$DEPARTAMENTO= gsub("Departamento de Lima","LIMA PROVINCIAS",Cap010_2$DEPARTAMENTO)
X2_2_2$DEPARTAMENTO= gsub("Prov. Const. del Callao","Callao",X2_2_2$DEPARTAMENTO)
X2_2_2$DEPARTAMENTO= gsub("Provincia de Lima","LIMA",X2_2_2$DEPARTAMENTO)
X2_2_2$DEPARTAMENTO= gsub("Región Lima","LIMA PROVINCIAS",X2_2_2$DEPARTAMENTO)
X2_2_2 = merge(X2_2_2, Cap010_2, by = "DEPARTAMENTO")
colnames(X2_2_2)[c(2:12)] = paste0("ODS2_2_2_",colnames(X2_2_2)[c(2:12)])
str(X2_2_2)
'data.frame': 34 obs. of 12 variables:
$ DEPARTAMENTO : chr "Amazonas" "Áncash" "Apurímac" "Arequipa" ...
$ ODS2_2_2_2010: chr "0.6" "0.3" "0.3" "0.5" ...
$ ODS2_2_2_2011: chr "0.8" "0.3" "0.5" "0.3" ...
$ ODS2_2_2_2012: chr "0.7" "0.4" "0.5" "0" ...
$ ODS2_2_2_2013: chr "0.1" "0.3" "0.4" "0.8" ...
$ ODS2_2_2_2014: num 0.4 0.2 0.3 0.3 0.2 0.4 0 0.3 0.2 0.9 ...
$ ODS2_2_2_2015: num 0.7 0.6 1.2 0 0.9 0.6 0.5 0.4 1.8 1.4 ...
$ ODS2_2_2_2016: num 0.6 0.1 0.7 0 1.2 0.4 0.2 1.7 1.3 0.3 ...
$ ODS2_2_2_2017: num 1.3 0.1 0.6 0.7 0.7 0.5 0.2 0.8 0.3 0.6 ...
$ ODS2_2_2_2018: num 1.2 0.2 0.4 0.1 0.5 0.2 0 0.3 0.7 0.3 ...
$ ODS2_2_2_2019: num 1.1 0.1 0.1 0.1 0.6 1 0.2 0.8 0.2 0.1 ...
$ ODS2_2_2_2020: num 0.9385 0.0757 0.3944 0.1938 0.6927 ...
Merge
ODS_2 = Reduce(function(x, y) merge(x, y, by= "DEPARTAMENTO"), list(X2_2_1,X2_2_2))
ODS_2[,c(2:26)]=lapply(ODS_2[,c(2:26)], as.numeric)
Warning in lapply(ODS_2[, c(2:26)], as.numeric) :
NAs introduced by coercion
Warning in lapply(ODS_2[, c(2:26)], as.numeric) :
NAs introduced by coercion
Warning in lapply(ODS_2[, c(2:26)], as.numeric) :
NAs introduced by coercion
Warning in lapply(ODS_2[, c(2:26)], as.numeric) :
NAs introduced by coercion
Warning in lapply(ODS_2[, c(2:26)], as.numeric) :
NAs introduced by coercion
Warning in lapply(ODS_2[, c(2:26)], as.numeric) :
NAs introduced by coercion
Warning in lapply(ODS_2[, c(2:26)], as.numeric) :
NAs introduced by coercion
Warning in lapply(ODS_2[, c(2:26)], as.numeric) :
NAs introduced by coercion
Warning in lapply(ODS_2[, c(2:26)], as.numeric) :
NAs introduced by coercion
Warning in lapply(ODS_2[, c(2:26)], as.numeric) :
NAs introduced by coercion
Warning in lapply(ODS_2[, c(2:26)], as.numeric) :
NAs introduced by coercion
Merge
ODS = Reduce(function(x, y) merge(x, y, by= "DEPARTAMENTO"), list(ODS_1,ODS_2))
library(stringi)
Warning: package ‘stringi’ was built under R version 4.0.5
ODS$DEPARTAMENTO= stri_trans_general(str = toupper(ODS$DEPARTAMENTO), id = "Latin-ASCII")
library(reshape2)
Warning: package ‘reshape2’ was built under R version 4.0.5
Attaching package: ‘reshape2’
The following object is masked from ‘package:tidyr’:
smiths
library(stringi)
library(tidyverse)
library(lubridate)
Warning: package ‘lubridate’ was built under R version 4.0.5
Attaching package: ‘lubridate’
The following objects are masked from ‘package:base’:
date, intersect, setdiff, union
ODSTrans= ODS %>% gather( ODS_Ano, Valor, 2:62, na.rm = TRUE, convert = FALSE)
ODSTrans$Ano= sub('.*(\\d{4}).*', '\\1', ODSTrans$ODS_Ano)
ODSTrans$Ano = as.Date(as.character(ODSTrans$Ano), format = "%Y")
ODSTrans$Ano<- year(ODSTrans$Ano)
ODSTrans$ODSNro= str_extract(ODSTrans$ODS_Ano,'[0-9]\\_[0-9]\\_[0-9]')
library(sf)
library(ggplot2)
library(ggpubr)
library(tidyverse)
library(ggrepel)
Warning: package ‘ggrepel’ was built under R version 4.0.5
library(repr)
Warning: package ‘repr’ was built under R version 4.0.5
library(dygraphs)
Warning: package ‘dygraphs’ was built under R version 4.0.5
library(quantmod)
Warning: package ‘quantmod’ was built under R version 4.0.5
Loading required package: xts
Warning: package ‘xts’ was built under R version 4.0.5
Loading required package: zoo
Warning: package ‘zoo’ was built under R version 4.0.5
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:
as.Date, as.Date.numeric
Attaching package: ‘xts’
The following object is masked from ‘package:leaflet’:
addLegend
The following objects are masked from ‘package:dplyr’:
first, last
Loading required package: TTR
Warning: package ‘TTR’ was built under R version 4.0.5
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
library(rjson)
Warning: package ‘rjson’ was built under R version 4.0.3
download.file("https://github.com/ChiaraZamoraM/ODS/raw/main/mapa_Peru/mapa_depas_Lima.zip",
destfile = "mapa_depas_Lima.zip" , mode='wb')
trying URL 'https://github.com/ChiaraZamoraM/ODS/raw/main/mapa_Peru/mapa_depas_Lima.zip'
Content type 'application/zip' length 1091127 bytes (1.0 MB)
downloaded 1.0 MB
unzip("mapa_depas_Lima.zip", exdir = ".")
file.remove("mapa_depas_Lima.zip")
[1] TRUE
mapa <- st_read("mapa_depas_Lima.shp")
Reading layer `mapa_depas_Lima' from data source
`C:\Users\soyma\Documents\GitHub\ODS\mapa_depas_Lima.shp' using driver `ESRI Shapefile'
Simple feature collection with 26 features and 3 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -81.3281 ymin: -18.35093 xmax: -68.65228 ymax: -0.03860597
Geodetic CRS: WGS 84
download.file("https://github.com/ChiaraZamoraM/ODS/raw/main/mapa2_Peru/Provincias_Peru.zip",
destfile = "Provincias_Peru.zip" , mode='wb')
trying URL 'https://github.com/ChiaraZamoraM/ODS/raw/main/mapa2_Peru/Provincias_Peru.zip'
Content type 'application/zip' length 8119766 bytes (7.7 MB)
downloaded 7.7 MB
unzip("Provincias_Peru.zip", exdir = ".")
file.remove("Provincias_Peru.zip")
[1] TRUE
mapa_prov <- st_read("PROVINCIAS.shp")
Reading layer `PROVINCIAS' from data source `C:\Users\soyma\Documents\GitHub\ODS\PROVINCIAS.shp' using driver `ESRI Shapefile'
Simple feature collection with 196 features and 6 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -81.32823 ymin: -18.35093 xmax: -68.65228 ymax: -0.03860597
Geodetic CRS: WGS 84
mapa_prov$DEPARTAMEN <- ifelse(mapa_prov$PROVINCIA == "LIMA", "LIMA METROPOLITANA", mapa_prov$DEPARTAMEN)
mapa_prov= fortify(mapa_prov)
mapaODS = merge(mapa, ODSTrans,
by.x='DEPARTAMEN',by.y="DEPARTAMENTO")
#mapaODS <- mapaODS %>% mutate(centroid = map(geometry, st_centroid),
# coords = map(centroid, st_coordinates),
# coords_x = map_dbl(coords, 1),
# coords_y = map_dbl(coords, 2))
subset1_1_1= subset(mapaODS, ODSNro=="1_1_1" & Ano> 2014)
base1_1_1= ggplot(data = subset1_1_1) + theme_light()
library(plotly)
mapaley1 = base1_1_1 +
geom_sf(aes(fill= Valor)) + labs(fill = "Porcentaje (%)") +
geom_sf(data = mapa_prov,
fill = NA) +
facet_wrap(~Ano)
mapa1 = mapaley1 +
scale_fill_gradient(low = "lightpink", high = "firebrick2")+
labs(title = "Incidencia de la pobreza extrema", subtitle = "Indicador 1.1.1")
mapa1

subset1_2_1= subset(mapaODS, ODSNro=="1_2_1" & Ano> 2014)
base1_2_1= ggplot(data = subset1_2_1) + theme_light()
library(plotly)
mapaley2 = base1_2_1 +
geom_sf(aes(fill= Valor)) + labs(fill = "Porcentaje (%)") +
geom_sf(data = mapa_prov,
fill = NA) +
facet_wrap(~Ano)
mapa2 = mapaley2 +
scale_fill_gradient(low = "lightpink", high = "firebrick2")+
labs(title = "Incidencia de la pobreza monetaria total", subtitle = "Indicador 1.2.1")
mapa2

subset1_3_1= subset(mapaODS, ODSNro=="1_3_1" & Ano> 2014)
base1_3_1= ggplot(data = subset1_3_1) + theme_light()
library(plotly)
mapaley3 = base1_3_1 +
geom_sf(aes(fill= Valor)) + labs(fill = "Porcentaje (%)") +
geom_sf(data = mapa_prov,
fill = NA) +
facet_wrap(~Ano)
mapa3 = mapaley3 +
scale_fill_gradient(low = "lightpink", high = "firebrick2")+
labs(title = "Proporción de población de 14 a más años de edad \ncon seguro de pensión", subtitle = "Indicador 1.3.1")
mapa3

subset1_4_1= subset(mapaODS, ODSNro=="1_4_1" & Ano> 2014)
base1_4_1= ggplot(data = subset1_4_1) + theme_light()
library(plotly)
mapaley4 = base1_4_1 +
geom_sf(aes(fill= Valor)) + labs(fill = "Porcentaje (%)") +
geom_sf(data = mapa_prov,
fill = NA) +
facet_wrap(~Ano)
mapa4 = mapaley4 +
scale_fill_gradient(low = "lightpink", high = "firebrick2")+
labs(title = "Proporción de la población que vive en hogares con \nacceso a servicios básicos de infraestructura", subtitle = "Indicador 1.4.1")
mapa4

library(leaflet)
pal1 = colorNumeric(palette = "Blues", domain = subset1_1_1$Valor)
names(subset1_1_1)
[1] "DEPARTAMEN" "IDDPTO" "id" "ODS_Ano" "Valor"
[6] "Ano" "ODSNro" "geometry"
map1_interactive = subset1_1_1 %>%
st_transform(crs= "+init=epsg:4326") %>%
leaflet() %>%
addProviderTiles(provider= "CartoDB.Positron") %>%
addPolygons(label= subset1_1_1$DEPARTAMEN,
stroke = FALSE,
smoothFactor = .5,
opacity = 1,
fillOpacity = 0.7,
fillColor = ~pal1(Valor),
highlightOptions = highlightOptions(weight = 5,
fillOpacity= 1,
color = "black",
opacity = 1,
bringToFront = TRUE))%>%
addLegend("bottomright",
pal = pal1,
values = ~Valor,
title= "Porcentaje (%)",
opacity= 0.7)
map1_interactive